package com.cn.ycy.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

@Service
public class AccessTokenServiceImpl {

  Logger logger = LoggerFactory.getLogger(AccessTokenServiceImpl.class);

  /**
   * 从配置的 springboot.properties 中读取
   */
  @Value("${spring.helloworld}")
  public String vfromSpring;

//  /**
//   * app.properties读取不到数据，同时也会报错
//  IllegalArgumentException:
//  Could not resolve placeholder 'app.info' in value "${app.info}"
//   */
//  @Value("${app.info}")
//  public String vfromOtherProperties;

  /**
   * 阿波罗配置
   */
  @Value("${apollo.helloworld}")
  public String vFromApollo;


  @PostConstruct
  public void getV() {
    logger.warn(vfromSpring);

//    logger.warn(vfromOtherProperties);

    logger.warn(vFromApollo);

//    new Thread(new Runnable() {
//      @Override
//      public void run() {
//        while(true){
//          logger.warn(vFromApollo);
//          try {
//            TimeUnit.SECONDS.sleep(5);
//          } catch (InterruptedException e) {
//            e.printStackTrace();
//          }
//        }
//      }
//    }).start();

  }


}
